﻿using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using System.Windows.Data;

namespace SharepointUpload
{
    public class DataSourceTranslation
    {
        public List<SPService.WebSiteInfo> allWebs;
        public List<SPService.WebSiteInfo> webLists;
        public List<SPService.FieldInfo> fieldInfo;
        public List<SPService.SPLookup> fieldValues;
    }
    public class SPFieldConverter : IValueConverter
    {
        #region IValueConvert Members
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (parameter != null)
            {
                SPService.FieldInfo field = (SPService.FieldInfo)value;
                switch (field.Type)
                {
                    case "Microsoft.SharePoint.SPFieldLookup":
                        return typeof(SPLookup);
                        break;
                    case "Microsoft.SharePoint.SPFieldBoolean":
                        return typeof(bool);
                        break;
                    case "Microsoft.SharePoint.SPFieldChoice":
                        return typeof(SPLookup);
                        break;
                    case "Microsoft.SharePoint.SPFieldCurrency":
                        return typeof(double);
                        break;
                    case "Microsoft.SharePoint.SPFieldDateTime":
                        return typeof(DateTime);
                        break;
                    case "Microsoft.SharePoint.SPFieldMultiChoice":
                        return null;
                        break;
                    case "Microsoft.SharePoint.SPFieldMultiColumn":
                        return null;
                        break;
                    case "Microsoft.SharePoint.SPFieldLineText":
                        return typeof(string);
                        break;
                    case "Microsoft.SharePoint.SPFieldNumber":
                        return typeof(int);
                        break;
                    case "Microsoft.SharePoint.SPFieldRatingScale":
                        return null;
                        break;
                    case "Microsoft.SharePoint.SPFieldUrl":
                        return typeof(SPLookup);
                        break;
                    case "Microsoft.SharePoint.SPFieldText":
                        return typeof(string);
                        break;
                    case "Microsoft.SharePoint.SPFieldUser":
                        return typeof(SPLookup);
                        break;
                }
            }
            return null;
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (parameter != null)
            {
                return value;
            }
            return null;
        }
        #endregion
    }
}
